﻿<Window x:Class="RTBExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="396" Width="561">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Margin="10">
            <Button Command="EditingCommands.ToggleBold" 
                CommandTarget="{Binding ElementName=_richTextBox}"
                Content="B"
                FontWeight="Bold"
                MinWidth="25"/>
            <Button Command="EditingCommands.ToggleItalic" 
                CommandTarget="{Binding ElementName=_richTextBox}"
                Content="I"
                FontStyle="Italic"
                MinWidth="25"/>

            <Button Command="EditingCommands.ToggleUnderline" 
                CommandTarget="{Binding ElementName=_richTextBox}"
                Content="U"
                MinWidth="25"/>

            <Button Command="EditingCommands.IncreaseFontSize" 
                CommandTarget="{Binding ElementName=_richTextBox}"
                Content="F+"
                MinWidth="25"/>
            
            <Button Command="EditingCommands.DecreaseFontSize" 
                CommandTarget="{Binding ElementName=_richTextBox}"
                Content="F-"
                MinWidth="25"/>

        </StackPanel>
        <RichTextBox x:Name="_richTextBox" Grid.Row="1" Margin="10,10,10,67" BorderBrush="Gray" Padding="10"
                                     
                                     ScrollViewer.VerticalScrollBarVisibility="Auto">
            <RichTextBox.CommandBindings>
                <CommandBinding Command="EditingCommands.ToggleBold"/>
                <CommandBinding Command="EditingCommands.ToggleItalic"/>
                <CommandBinding Command="EditingCommands.ToggleUnderline"/>
                <CommandBinding Command="EditingCommands.IncreaseFontSize"/>
                <CommandBinding Command="EditingCommands.DecreaseFontSize"/>
            </RichTextBox.CommandBindings>
        </RichTextBox>
        <Button Content="Set" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="89,274,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
        <Button Content="Clear" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="234,274,0,0" Name="button2" VerticalAlignment="Top" Width="75" Click="button2_Click" />
        <Button Content="Load" Grid.Row="1" Height="23" HorizontalAlignment="Right" Margin="0,274,88,0" Name="button3" VerticalAlignment="Top" Width="75" Click="button3_Click" />
    </Grid>
</Window>
